package com.wago.controller;

import com.wago.dao.StudentDao;
import com.wago.entity.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by "鐤媯鐨勭爜宸�" on 2017-09-11.
 */
@Controller
public class StudentController {

    @Autowired
    private StudentDao dao;

    @RequestMapping("/fan.do")
    public String fan(Model m) {
        m.addAttribute("student", dao.student(2));
        return "fan";

    }
    @RequestMapping("/insert.do") @ResponseBody
    public String inse(String sname,double score,String saddress){
    Student s=new Student();
    s.setSname(sname);
    s.setScore(score);
    s.setSaddress(saddress);
    int a=dao.insert(s);
    if(a>0){
        System.out.println("插入成功");
    }else {
        System.out.println("插入失败");
    }
        return "插入成功";
    }

}